//
//  UserAccount.swift
//  Webo10
//
//  Created by ChengXiwu on 2017/7/29.
//  Copyright © 2017年 ChengXiwu. All rights reserved.
//

import UIKit

/**
     {
         "access_token" = "2.00A6tkOB0UjJZsf5f5f7d988glL4yB";
         "expires_in" = 157679999;
         "remind_in" = 157679999;
         uid = 1134177594;
     }
 */

class UserAccount: BasicModel{
    
    // 用户授权的唯一票据，用于调用微博的开放接口
    var access_token: String?
    // access_token的生命周期，单位是秒数
    var expires_in: TimeInterval = 0 {
        didSet{
            // 计算过期日期
            expiresDate = Date(timeIntervalSinceNow: expires_in)
        }
    }
    // 定义过期日期
    var expiresDate: Date?
        
    // 授权用户的UID
    var uid: String?
    
    // 用户昵称
    var screen_name: String?
    // 用户头像url
    var avatar_large: String?
    
    
    // 保存当前对象
    func saveUserAccount(){
        // 归档保存
        NSKeyedArchiver.archiveRootObject(self, toFile: ARCHIVE_PATH)
    }
    
}
